package com.demo.web;

import com.demo.dto.ListResult;
import com.demo.dto.Pagination;
import com.demo.entity.StatisticShare;
import com.demo.service.IStatisticShareService;
import com.demo.vo.StatisticShareVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by byte2 on 2017-04-01.
 */
@Controller
@RequestMapping("/admin/statistic")
public class StatisticController {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private IStatisticShareService ssService;
    @ResponseBody
    @RequestMapping(value = "/queryShare", method = RequestMethod.GET)
    public ListResult query(StatisticShareVo arg) {
        List<StatisticShare> list = ssService.queryByPage(arg);
        int total = ssService.queryCount(arg);
        Pagination page = new Pagination(arg.getPage(), total, arg.getSize());
        ListResult res = new ListResult(true, list);
        res.setPage(page);
        return res;
    }

    @ResponseBody
    @RequestMapping(value = "/queryShareBySaleGroup", method = RequestMethod.GET)
    public ListResult queryBySaleGroup(StatisticShareVo arg) {
        List<StatisticShareVo> list = ssService.queryByPageByGroup(arg);
        int total = ssService.queryCountByGroup(arg);
        Pagination page = new Pagination(arg.getPage(), total, arg.getSize());
        ListResult res = new ListResult(true, list);
        res.setPage(page);
        return res;
    }
}
